package com.xhd.xml;

import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

import com.xhd.server.ServerConfig;

public class XMLData {
	private  String Text = null;
	  private byte[] aramArray = null;
	  private int FlushSize = 0;
	  private int jm628 = 6;
	  private static final int jm629 = 1;
	  public static final int OUT_DATA_FLAG = 2;
	  public static final int OUT_ZIP_FLAG = 4;

	  public XMLData(boolean paramBoolean)
	  {
	    setOutputOption(1, paramBoolean);
	  }

	  public void setFlushSize(int paramInt)
	  {
	    this.FlushSize = paramInt;
	  }

	  public boolean isZip()
	  {
	    return (1 == (this.jm628 & 0x1));
	  }

	  public void setText(String paramString)
	  {
	    this.Text = paramString;
	  }

	  public void setText(byte[] paramArrayOfByte)
	  {
	    this.aramArray = paramArrayOfByte;
	  }

	  public void output(OutputStream paramOutputStream)
	    throws IOException
	  {
	    if ((((this.aramArray == null) || (this.aramArray.length < 1))) && (((this.Text == null) || (this.Text.length() < 1))))
	      return;
	    int i = (1 == (0x1 & this.jm628)) ? 1 : 0;
	    int j = (2 == (0x2 & this.jm628)) ? 1 : 0;
	    if (j != 0)
	      paramOutputStream.write(3);
	    if (4 == (0x4 & this.jm628))
	      paramOutputStream.write((i != 0) ? 2 : 1);
	    if (this.aramArray != null)
	      if ((this.FlushSize > 0) && (this.aramArray.length > this.FlushSize))
	      {
	        int k = 0;
	        for (int l = this.FlushSize; l > 0; l = this.aramArray.length - k)
	        {
	          paramOutputStream.write(this.aramArray, k, l);
	          paramOutputStream.flush();
	          k += l;
	          label183: if (k + l <= this.aramArray.length)
	            break label183;
	        }
	      }
	      else
	      {
	        paramOutputStream.write(this.aramArray);
	      }
	    else
	      paramOutputStream.write(this.Text.getBytes(ServerConfig.XMLEncode));
	    if (j != 0)
	      paramOutputStream.write(3);
	    paramOutputStream.flush();
	  }

	  public void output(OutputStream paramOutputStream, boolean paramBoolean)
	    throws IOException
	  {
	    int i = this.jm628;
	    this.jm628 &= -3;
	    if (paramBoolean)
	      this.jm628 |= 2;
	    this.jm628 = i;
	    output(paramOutputStream);
	  }

	  public int getSize()
	  {
	    if ((((this.aramArray == null) || (this.aramArray.length < 1))) && (((this.Text == null) || (this.Text.length() < 1))))
	      return 0;
	    int i = 0;
	   
	    try
	    {
	      if (this.aramArray != null)
	      {
	        i = this.aramArray.length;
	          i += 2;
	      }
	      i = this.Text.getBytes(ServerConfig.XMLEncode).length;
	    }
	    catch (Exception localException)
	    {
	    }
	    if (2 == (0x2 & this.jm628))
		      label70: i += 2;
        if (4 == (0x4 & this.jm628))
		      ++i;
	    return i;
	  }

	  public String getXMLText()
	    throws UnsupportedEncodingException
	  {
	    if ((((this.aramArray == null) || (this.aramArray.length < 1))) && (((this.Text == null) || (this.Text.length() < 1))))
	      return null;
	    if (this.aramArray != null)
	      return new String(this.aramArray, ServerConfig.XMLEncode);
	    return this.Text;
	  }

	  public int getOutputOptions()
	  {
	    return this.jm628;
	  }

	  public void setOutputOption(int paramInt, boolean paramBoolean)
	  {
	    this.jm628 &= (paramInt ^ 0xFFFFFFFF);
	    if (!(paramBoolean))
	      return;
	    this.jm628 |= paramInt;
	  }
}
